<include file="public@header"/>
<script type="text/html" id="photos-item-tpl">
    <li id="saved-image{id}">
        <input id="photo-{id}" type="hidden" name="photo_urls[]" value="{filepath}">
        <input class="layui-input" id="photo-{id}-name" type="text" name="photo_names[]" value="{name}"
               style="width: 200px;" title="图片名称">
        <img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;"
             onclick="imagePreviewDialog(this.src);">
        <a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>
        <a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
    </li>
</script>
<script type="text/html" id="files-item-tpl">
    <li id="saved-file{id}">
        <input id="file-{id}" type="hidden" name="file_urls[]" value="{filepath}">
        <input class="layui-input" id="file-{id}-name" type="text" name="file_names[]" value="{name}"
               style="width: 200px;" title="文件名称">
        <a id="file-{id}-preview" href="{preview_url}" target="_blank">下载</a>
        <a href="javascript:uploadOne('附件上传','#file-{id}','file');">替换</a>
        <a href="javascript:(function(){$('#saved-file{id}').remove();})();">移除</a>
    </li>
</script>
</head>
<body>
<div class="layui-fluid js-check-wrap">
    <div class="layui-card">
        <div class="layui-card-header">维修单</div>

        <form action="{:url('AdminArticle/editApplyPost')}" method="post" class="layui-form js-ajax-form" data-replace="1">
            <div class="layui-card-body">
                <div class="layui-tab">
                    <ul class="layui-tab-title">
                        <li class="layui-this">
                            <span class="icon-wrapper"><i class="fa fa-align-center"></i></span>
                            <span class="text-wrapper">维修单</span>
                        </li>
                        <!-- <li>
                            <span class="icon-wrapper"><i class="fa fa-cog"></i></span>
                            <span class="text-wrapper">{:lang('SEO_OPT')}</span>
                        </li> -->
                    </ul>

                    <div class="layui-tab-content">
                        <div class="layui-tab-item layui-show">
                            <div class="layui-card-body">
                                <!-- 标题 -->
                                <div class="layui-form-item">
                                    <label class="layui-form-label">故障标题</label>
                                    <div class="layui-input-block">
                                        <input type="hidden" name="repair_id" value="{$repair_info.repair_id}">
                                        <input class="layui-input form-replace" type="text" id="title"
                                                value="{$repair_info.post_title}" readonly />
                                    </div>
                                </div>

                                <div class="layui-form-item">
                                    <label class="layui-form-label">故障类别</label>
                                    <div class="layui-input-block">
                                        <input class="layui-input form-replace" type="text" id="category"
                                                value="{$repair_info.category_name}"  readonly />
                                    </div>
                                </div>

                                <!-- 故障地点 -->
                                <div class="layui-form-item">
                                    <label class="layui-form-label">故障地点</label>
                                    <div class="layui-input-block">
                                        <input class="layui-input form-replace" type="text" id="repair_place"
                                               value="{$repair_info.repair_place}" data-field="repair_place">
                                    </div>
                                </div>
                                
                                
                                <!-- 申请时间 -->
                                <div class="layui-form-item">
                                    <label class="layui-form-label">申请时间</label>
                                    <div class="layui-input-block">
                                        <div class="input-group">
                                            <input class="layui-input" type="text"
                                                   value="{:date('Y-m-d H:i:s',$repair_info.create_time)}" id="published_time" readonly>
                                        </div>
                                    </div>
                                </div>

                                <!-- 故障内容 -->
                                <div class="layui-form-item">
                                    <label class="layui-form-label">{:lang('REPAIR_CONTENT')}</label>
                                    <div class="layui-input-block">
                                        <textarea style=" width: 100%;height: 100px;border: 1px #ddd solid;border-radius: 2px; padding: 10px; font-size:14px" readonly>{$repair_info.post_content}</textarea>
                                    </div>
                                </div>


                                <!-- 相册 -->
                                <div class="layui-form-item">
                                    <label class="layui-form-label">{:lang('ALBUM')}</label>
                                    <div class="layui-input-block">
                                        <ul id="photos" class="pic-list list-unstyled form-inline">
                                            <notempty name="repair_info.photos">
                                                <foreach name="repair_info.photos" item="vo">
                                                    <php>$img_url=cmf_get_image_preview_url($vo);</php>
                                                    <li id="saved-image{$key}">
                                                        <img id="photo-{$key}-preview"
                                                             src="{:cmf_get_image_preview_url($vo)}" title="点击放大"
                                                             style="height:100px;width: 100px;"
                                                             onclick="parent.imagePreviewDialog(this.src);">
                                                    </li>
                                                </foreach>
                                            </notempty>
                                        </ul>
                                    </div>
                                </div>


                                <!-- 选择维修人员 -->
                                <div class="layui-form-item">
                                    <label class="layui-form-label">维修人员</label>
                                    <div class="layui-input-block">
                                        <input class="layui-input form-replace" type="text"
                                               value="{$repair_info.repairman.user_login}" readonly>
                                    </div>
                                </div>

                            </div>
                        </div>
        
                    </div>
                </div>

                <div class="layui-form-item padding-left-25">
                    <div class="layui-input-block">
                        <!-- <button type="button" class="layui-btn layui-btn-normal" onclick="CheckSenSubmit('/repair/AdminArticle/editApplyPost');" id="add-key">{:lang('SAVE')}</button> -->
                        <if condition="$repair_info.repair_status neq 3">
                        <input type="submit" class="layui-btn layui-btn-normal js-ajax-submit" id="js-ajax-submit" value="通过申请" name="submit">
                        <input type="submit" class="layui-btn layui-btn-normal js-ajax-submit" id="js-ajax-submit" value="拒绝申请" name="submit">
                        </if>
                        <a class="layui-btn layui-btn-primary" href="javascript:history.back(-1);">{:lang('BACK')}</a>
                    </div>
                </div>
                    
            </div>
        </form>
    </div>
</div>

<include file="public@footer"/>
<include file="admin@theme/scripts"/>
<script type="text/javascript">
    //编辑器路径定义
    var editorURL = GV.WEB_ROOT;
</script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.js"></script>
<script type="text/javascript">
    $(function () {
        if( $('#detail_content').length ){
            // $('.content-preview').show();
            UE.getEditor('detail_content');
        }

        if( $('#post_excerpt').length ){
            UE.getEditor('post_excerpt');
        }
        

        $('.btn-cancel-thumbnail').click(function () {
            $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
            $('#thumbnail').val('');
        });

        $('#more-template-select').val("{$post.more.template|default=''}");
    });

    function doSelectCategory() {
        var selectedCategoriesId = $('#js-categories-id-input').val();
        openIframeLayer("{:url('AdminCategory/select')}?operate=edit&ids=" + selectedCategoriesId, '请选择分类', {
            area: ['700px', '400px'],
            btn: ['确定', '取消'],
            yes: function (index, layero) {
                //do something

                var iframeWin          = window[layero.find('iframe')[0]['name']];
                var selectedCategories = iframeWin.confirm();
                if (selectedCategories.selectedCategoriesId.length == 0) {
                    layer.msg('请选择分类');
                    return;
                }
                $('#js-categories-id-input').val(selectedCategories.selectedCategoriesId.join(','));
                $('#js-categories-name-input').val(selectedCategories.selectedCategoriesName.join(' '));
                //console.log(layer.getFrameIndex(index));
                layer.close(index); //如果设定了yes回调，需进行手工关闭
            }
        });
    }
</script>

